var app =new Vue({
    el:"#container",
    data:{
        user:{},
        oldPassword:"",
        password:"",
        affirm:""
    },
    mounted(){
        this.userInfo();
    },
    methods:{
        userInfo(){
            axios({
                url:"yly-api/admin/queryEmpAccountByToken",
                method:"get",
                headers:{"token":localStorage.token,"url":window.location.pathname}
            }).then(function (res) {
                console.log(res);
                app.user=res.data;
            }).catch(function (error) {
                console.log(error.response.status);
                if (error.response.status==401){
                    alert("权限不足，无法访问!");
                    location.href="login.html";
                }else if (error.response.status==403){
                    alert("用户已过期，请重新登录！");
                    localStorage.token=null;
                    location.href="login.html";
                }
            })
        },
        pwd(){
            let data=new URLSearchParams();
            data.append("password",app.oldPassword);
            axios({
                url:"yly-api/admin/judgePwd",
                data:data,
                headers:{"token":localStorage.token,"url":window.location.pathname},
                method: "post"
            }).then(function (res){
                if(res.data=="success"){
                    $(".error").html("密码输入正确！");
                }else {
                    $(".error").html("密码错误，请重新输入！");
                    app.oldPassword="";
                }
            }).catch(function (error) {
                console.log(error.response.status);
                if (error.response.status==401){
                    alert("权限不足，无法访问!");
                    location.href="login.html";
                }else if (error.response.status==403){
                    alert("用户已过期，请重新登录！");
                    localStorage.token=null;
                    location.href="login.html";
                }
            })
        }
    }
})